

var TextExtend = function( action, vars )	{
	
	Object.extend( obj = $$( '.TextExtend' ).pop(), TextExtend[ "proto_" + action ]);
	
	obj.vars = vars;
	return obj.init();	
}



// ACTION SPECIFIC PROTO'S
TextExtend.proto_numslide = {
	init		: function() {
		
		child = this.vars.children[0];
		img	= "/public.img?sze=" + this.vars.imgsize + "&id=" + child.imgid; 
		
		this.update( this.cont = new Element( "div", { "class":"cont", "style":"background-image:url(" + img + ")" }).insert( this.nums = new Element( "span", { "class":"nums" })).insert( descr = new Element( "span", { "class":"descr" })));
		descr.insert( this.h1 = new Element( "h1" ).update( child.title ));
		descr.insert( this.p = new Element( "p" ).update( child.descr ));
		descr.insert( this.a = new Element( "a", { "href": child.link }).update( "meer" ));
		
		this.vars.children.each( function( v, n ) { this.nums.insert( new Element( "span" ).update( n+1 ).observe( "click", this.set.bind( this ))); }, this );
		this.nums.down(0).addClassName( "active" );
		
		return this;
	},
	
	set			: function( e ) {
		
		this.nums.select( "span" ).invoke( "removeClassName", "active" );
		num = e.element( e ).addClassName( "active" );
		
		this.cont.fade({ duration: .4 });
		this.flip.delay( 0.42, this, this.vars.children[ Number( num.innerHTML ) - 1 ]);
	},
	
	flip	: function( obj, child ){
		
		obj.cont.setStyle({ backgroundImage: "url(/public.img?sze=" + obj.vars.imgsize + "&id=" + child.imgid + ")" });
		obj.h1.update( child.title );
		obj.p.update( child.descr );
		obj.a.href = child.link;
			
		obj.cont.appear({ duration: 2 });
	}
	
}